﻿using System;
using System.Text;

public class HexadecimalToBinaryDirectlyConversion
{
    public static void Main()
    {
        HexadecimalToBinaryDirectly("Problem 5: Hexadecimal to Binary Directly conversion");
    }

    public static void HexadecimalToBinaryDirectly(string description)
    {
        string number = ConversionBetweenNumeralSystems.InputNumber(description, 16);
        string minus = "";
        StringBuilder construct = new StringBuilder();
        string part;

        if (number[0] == '-')
        {
            minus = "-";
            number = number.Remove(0, 1);
        }

        number = ConversionBetweenNumeralSystems.RemoveLeadingZeros(number);

        for (int i = 0; i < number.Length; i++)
        {
            part = ConversionBetweenNumeralSystems.Convert(number[i].ToString(), 16, 2);
            construct.Append(new string('0', (4 - part.Length)) + part);
        }

        Console.Clear();
        Console.WriteLine(description + "\n" + minus + number + "(16) = " 
            + minus + ConversionBetweenNumeralSystems.RemoveLeadingZeros(construct.ToString()) + "(2)");
    }
}